<!DOCTYPE html>
<html lang="en"  ng-app>
<head>
    <meta charset="UTF-8">
    <script src="../jsLib/angular-1.3.0.js"></script>
    <title></title>
</head>
<body>
<div ng-controller="ParentCtrl">
     <h3 style="color: red">{{aa}}</h3>
    <div ng-controller="SelfCtrl">
        <h3 style="color: red">{{aa}}</h3>
        <a class="btn" ng-click="click()">click me</a>
        <div ng-controller="ChildCtrl">
            child{{aa}}
        </div>

    </div>

    <div ng-controller="BroCtrl">
        <h3 style="color: red">{{aa}}</h3>
    </div>
</div>
<script>
    function ParentCtrl($scope){
        $scope.aa='hello world';
        $scope.$on('to-parent', function (e,bb,cc) {
            $scope.aa=' 用事件的方式在父作用域和子作用域传播数据'+bb;
            alert(bb+" "+cc)
        });
    }
    function SelfCtrl($scope){
        $scope.click = function(){
            $scope.$emit('to-parent', 'parent','hello');
            $scope.$broadcast('to-child', 'child');
        }

    }
    function ChildCtrl($scope){
        $scope.$on('to-child', function (e,bb,cc) {
            $scope.aa=bb;
             alert($scope.aa)
        });
    }
    function BroCtrl(){

    }
</script>
</body>
</html>